home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*
- * Simple code to support stereo windows
- */
-
- #include <stdio.h>
- #include <malloc.h>
-
- #define USE_X
-
- #include "stereo.h"
- #include "glxhelper.h"
-
- #include "SGIStereo.h"
-
- typedef struct StereoWindow
- {
- long st_id;
-
- Window win;
-
- struct StereoWindow *next, *prev;
- } StereoWindow;
-
- static StereoWindow *head = NULL;
- static int numwindows = 0;
-
- Display * dpy;
-
- long
- st_winopen(char *title, int primary, int *softStereo)
- {
- Window root,glW;
- int screen_num;
- XEvent event;
- XSizeHints hints;
- int ival, status;
-
- Window retroot, tmpWin;
- int ox, oy;
- unsigned int sx, sy, bw, depth;
-
- StereoWindow *new_window;
-
- if((dpy=XOpenDisplay(0)) == NULL) {
- fprintf(stderr,"\ncannot connect to X server\n");
- exit(-1);
- }
-
- screen_num = DefaultScreen(dpy);
- root = RootWindow(dpy,screen_num);
-
- if(XSGIStereoQueryExtension(dpy, &ival, &status))
- {
- printf("SoftStereo supported\n");
- *softStereo = TRUE;
- }else{
- printf("SoftStereo NOT supported\n");
- *softStereo = FALSE;
- exit(1);
- }
-
- if (numwindows == 0)
- {
- foreground();
- noport();
- winopen(title); /* Initialize graphics, then... */
- if(!softStereo)
- stereo_on(STR_RECT);
- else
- stereo_on(primary); /* Turn on stereo mode */
- }
- ++numwindows;
-
- new_window = (StereoWindow *)malloc(sizeof(StereoWindow));
-
- new_window->st_id = numwindows;
-
- new_window->next = head;
- new_window->prev = NULL;
-
- head = new_window;
-
- new_window->win = GLXCreateWindow(dpy, root, 0, 0, 700, 400, 0, GLXrgbDoubleBuffer);
-
- XStoreName(dpy, new_window->win, title);
- XSelectInput(dpy,new_window->win,Button2MotionMask|
- PointerMotionHintMask | StructureNotifyMask |
- ButtonPressMask|ButtonReleaseMask|ExposureMask|KeyPressMask);
- XMapWindow(dpy,new_window->win);
- GLXwinset(dpy, new_window->win);
-
- XNextEvent(dpy, &event);
-
- XSync(dpy,False);
- return new_window->st_id;
- }
-
- static StereoWindow *
- find_window(long id)
- {
- StereoWindow *scan;
- for (scan = head; scan != NULL; scan = scan->next)
- {
- if (scan->st_id == id) break;
- }
- return scan;
- }
-
- void
- st_winclose(long id)
- {
- StereoWindow *w;
- if ((w = find_window(id)) != NULL)
- {
- /* Unlink from list */
- if (w == head)
- head = w->next;
- if (w->prev != NULL)
- w->prev->next = w->next;
- if (w->next != NULL)
- w->next->prev = w->prev;
-
- /* Free storage */
- free(w);
- }
- }
-
- void
- st_right(long st_id)
- {
- StereoWindow *w;
- if ((w = find_window(st_id)) != NULL)
- {
- XSGISetStereoBuffer(dpy, w->win, STEREO_BUFFER_RIGHT);
- XSync(dpy, False);
- }
- }
-
- void
- st_left(long st_id)
- {
- StereoWindow *w;
- if ((w = find_window(st_id)) != NULL)
- {
- XSGISetStereoBuffer(dpy, w->win, STEREO_BUFFER_LEFT);
- XSync(dpy, False);
- }
- }
-
-